using UnityEngine;
using System.Collections;

public class EnemyMove : MonoBehaviour
{
	public int speed = 100;
	public int dropTime = 20;
	public GameObject prefabBomb;
	public AudioSource Bomb;
	
	// Use this for initialization
	void Start () 
	{
	
	}
	
	// Update is called once per frame
	void Update ()
	{
		ComputerMove();
		BombDrop();
		
		if(dropTime == 0)
		{
			audio.Play();
			GameObject Bomb = (GameObject)Instantiate(prefabBomb, transform.position, transform.rotation);
		}
	}
	
	void ComputerMove()
	{
		Vector3 computerDirection = Vector3.left;
		
		transform.Translate(computerDirection * (speed * Time.deltaTime));
			
		if(transform.position.x > 126)
		{
			speed *= -1;
		}
		else if(transform.position.x < -126)
		{
			speed *= -1;
		}
	}
	
	void BombDrop()
	{
		if(dropTime > 0)
		{
			dropTime--;
		}
		else if(dropTime <=0)
		{
			dropTime = 50;
		}
	}
}